#ifndef __PREDEFINE_H__
#define  __PREDEFINE_H__

// RUIZD: TODO: Se podrÌa mergear Defines con PreDefine
#include "Defines.h"
#include "PreHeader.h"

//#pragma warning (disable: 4291)//for operator delete not match new 
//#pragma warning (disable: 4311)//conversion from pointer to 'u32'
//#pragma warning (disable: 4312)//conversion from 'u32' to pointer

//////////////////////////////////////////////////
//#ifdef _DEBUG
//#define IPHONE_CHEATS
#define SHOW_BOUND_RECT 0
#define _USE_CHEAT
#define CheatLockSystem
#define _USE_CHEAT_BASE
//#define FONT_TEST
//#endif

//#define SOUND_QUESTION

// Game ID
#define GAME_ID				0x1f000

#define USE_ANIMATED_BACKGROUNDS


#define PLATFORM		PLATFORM_WIN32
#define MEMORY_LEAK		1

#define INTERFACE_HEIGHT 45
#define MENU_AREA (SCREEN_HEIGHT - 2*INTERFACE_HEIGHT)
#define MENU_GAP 10


#define MAIN_MENU_GAP   31
#define MAIN_MENU_Y     67
#define MAIN_MENU_TEXT_Y (MAIN_MENU_Y+4)
#define MAIN_MENU_LOGO_Y_OFFSET 12
#define MAIN_MENU_BAR_Y 64
#define MAIN_MENU_BAR_GAP 33

#define SCREEN_WIDTH_D2	(SCREEN_WIDTH / 2)
#define SCREEN_HEIGHT_D2 (SCREEN_HEIGHT / 2)

//@brief Menu
#define InterfaceTopHeight 20
#define GameZoneH (SCREEN_HEIGHT_D2 + 60 - InterfaceTopHeight)
#define MenuBarH 44

//////////////////////////////////////////////////////////////////////////

#ifndef NULL
#define NULL 0
#endif

typedef signed char			T_S08;
typedef void				T_NUL;
typedef int					T_S32;
typedef unsigned int		T_U32;
typedef unsigned short		T_U16;
typedef unsigned char		T_U08;
typedef float				T_F32;
typedef short				T_S16;


typedef unsigned char  GL_TCHAR;
typedef unsigned int GL_UCHAR;

#define u16					T_U16
#define u32					T_U32
#define fx16				T_S16
#define u8					T_U08
//#define fx32  T_S32
#ifndef byte
#define byte  T_U08
#endif
#define VecFx32   T_U32

//typedef GLuint Texture;

#define MEMCPY memcpy
#define MEMSET memset
#define STRCPY(s,d)   strcpy(s, d)//Font::StrCpy(s, d)
#define STRLEN(s)     1//Font::StrLen(s)
#define STRUCPY(s,d)  1//Font::StrCpy(s, d)
#define STRCMP(s1,s2) strcmp(s1,s2)//Font::StrCmp(s1,s2)
#define STRCAT(s1,s2) 1//Font::StrCat(s1,s2)
#define null NULL

//typedef union
//{
//	struct
//	{
//		fx32    _00, _01, _02;
//		fx32    _10, _11, _12;
//		fx32    _20, _21, _22;
//		fx32    _30, _31, _32;
//	};
//	fx32    m[4][3];
//	fx32    a[12];
//}
//MtxFx43;


#define FX32_ONE 	(1.0f)
#define FX32_HALF	(0.5f)

#define SPRINTF	sprintf

void DebugOut(char* text, ...);

#define DBGOUT DebugOut

//#define G2D_PRIORIY_LOW     0
//#define G2D_PRIORIY_MEDIUM  1
//#define G2D_PRIORIY_HIGH    2

#define CheckP(p)		{if(p==NULL) return;}
#define SAFE_DELETE(p) do{if(p) {delete p; (p) = NULL;}}while(0)
#define SAFE_DELETE_ARRAY(p) do{if(p){delete[] p; (p) = NULL;}}while(0)
#define ZEROFILL(ary,size)	{ for (int zerocount = 0; zerocount < size; zerocount++) ary[zerocount] = 0; }


//#define Max(a,b)    (((a) > (b)) ? (a) : (b))
//#define Min(a,b)    (((a) < (b)) ? (a) : (b))
// left close
#define IsRange(x,min,max)   (x >= min && x < max)
#define SWAP(a,b)	{ a=a+b; b=a-b; a=a-b;}

#define TO_ARGB(a,r,g,b) ( ((a&0xff)<<24) | ((r&0xff)<<16) | ((g&0xff)<<8) | (b&0xff) )
#define TO_RGB(r,g,b) (((r&0xff)<<16)|((g&0xff)<<8)|(b&0xff)|0xff000000)

//#define TMP_BUFFER_SIZE			(50 * 1024)	/* 12k of mem - for 8888 */

extern short GetShort(char* p, int * offset);

//extern void    arraycopy( char * src, int srcPos, char * dest, int destPos, int length ) ;

// texture

// ASprite defined
//#define	bDbgO				!false
#include "ASprite_def.h"


//#define _TestEnable
#define _OptimizePaintFrame
#define USE_BUFFER_TEXTURE
//#define _DEMO

#ifdef _DEMO
#define _NOT_USE_FIRST_PLAY
extern int m_Layout;
#endif

#define MAGIC_NUM   0xB26C9B26
//show the  short time and longest time of playing one question
//#define __SHOW_OVERALL_PLAY_TIME 
//#endif
//#define USE_BS_MODULES_IMG

//#define Test_3D_Model
//#define  _USE_PALIMAGE_BUFFER


//#define USE_MUSIC_FADE_IN_OUT

//#define Output_Info
#ifdef Output_Info
extern GLuint sOutputInfoFontTextureName;
extern unsigned long gOutputInfo[];
#endif
#define	_USE_SHOW_ANSWER_ITEM

//#define _NOT_USE_FIRST_PLAY

#define UseLockSystem //!AC_ Temp

//#define _USE_CHEAT

//#define _CHEAT_ANSWER

// RUIZD: Comment the USE_IPL_USEID and USE_CALAMDER_FLIP
//#ifndef __M1A__
#define Use3DModel
#define Use321MatrixAnim
//#else
//#define USE_IPL_USEID
//#define USE_CALAMDER_FLIP
//#endif

//#define _Use_VBO

//@Game define
#define TRGameCategoryNum			5
#define TRGameNumPerCategory		5
#define TRGameStressCategoryNum		3
#define TRGameNumPerStressCategory	3
#define TRGameBonusCategoryNum		3
#define TRGameNumPerBonusCategory	3
#define TRBonusOffset				(TRGameCategoryNum + TRGameStressCategoryNum + 1)
#define TRGameDifficultNum			3
#define BonusGameNum				(TRGameBonusCategoryNum * TRGameNumPerBonusCategory)
#define GameTotalNum				(TRGameNumPerCategory*TRGameCategoryNum+TRGameStressCategoryNum*TRGameNumPerStressCategory)
#define GameStressNum				(TRGameStressCategoryNum*TRGameNumPerStressCategory)
#define CategoryCount				(TRGameCategoryNum + TRGameStressCategoryNum + 1 + TRGameBonusCategoryNum)
#define DailyMinigamesCount			(TRGameCategoryNum*TRGameNumPerCategory)
#define _UseSFXVolumeSlider


//@brief GameSave
#define SAVE_FILE_NAME				"bc.sav"
#define OPTIONS_FILE_NAME			"options.sav"
#define PROFILE_NUM					5
#define RECORD_PLAYER_SIZE			PROFILE_NUM
#define PROFILE_INDEX				1
#define PROFILE_NAME_MAX			8
#ifdef USE_IPHONE_LABEL_NAME
#define PROFILE_NAME_SIZE			PROFILE_NAME_MAX*3
#else
#define PROFILE_NAME_SIZE			PROFILE_NAME_MAX
#endif
#define RECORD_PLAYER_DATA_START    (sizeof(int)*2)
#ifdef USE_IPL_USEID
#define RECORD_SIZE					(sizeof(PlayerRecord)*RECORD_PLAYER_SIZE+RECORD_PLAYER_DATA_START+sizeof(int)*RECORD_PLAYER_SIZE)
#else
#define RECORD_SIZE					(sizeof(PlayerRecord)*RECORD_PLAYER_SIZE+RECORD_PLAYER_DATA_START)
#endif
#ifdef _UseSFXVolumeSlider
#define GENERAL_OPTIONS_LENGTH		5
#else
#define GENERAL_OPTIONS_LENGTH		2
#endif // _UseSFXVolumeSlider
#define OPTIONS_PROFILE_LENGTH		(GENERAL_OPTIONS_LENGTH + 2 + PROFILE_NAME_SIZE)
#define	OPTIONS_ARY_LENGTH			(OPTIONS_PROFILE_LENGTH * PROFILE_NUM)
#define OPTIONS_LENGTH				(3 + OPTIONS_ARY_LENGTH + 1)
#define JAFONT_HL_COLOR				0xffffffff
#define JAFONT_LL_COLOR				0xffffffff
#define JAFONT_TITLE_COLOR			0xffffffff

// RUIZD: Moved from game.h in order to reduce cross dependencies
enum Languages {
		LANG_NONE = -22,
		LANG_EN = 0,
		LANG_FR,
		LANG_SP,
		LANG_DE,
		LANG_IT,
		LANG_JP,
		LANG_COUNT
	};

#define I2F(i) (i<<8)
#define POINTER_TO_VAL(a) ((unsigned long)a & 0xFFFF)


//#define SHOW_VIDEO
#define USE_TUTORIAL_VFX

#define USE_TIME_DEBUG
#ifdef USE_TIME_DEBUG
	#include "TimeDebuger.h"
	#define	TIME_DEBUG_START_FRAME()	TimeDebuger::instance().StartFrame()
	#define	TIME_DEBUG_TIME_CHECK(str)	TimeDebuger::instance().TimeCheck(str)
	#define	TIME_DEBUG_SHOW_LOG()	TimeDebuger::instance().ShowLog()
#else
	#define	TIME_DEBUG_START_FRAME()
	#define	TIME_DEBUG_TIME_CHECK(str)
	#define	TIME_DEBUG_SHOW_LOG()
#endif

#endif



